package company.jingdong;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 * 京东笔试1
 *
 * @author briarbear
 * @blog http://briarbear.github.io
 * @create 2018-09-09-19:44
 */
public class J01 {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int t = scanner.nextInt();
        for (int i = 0; i < t; i++) {
            int n = scanner.nextInt(); //n个点
            int m = scanner.nextInt(); //m条边
            int[][] links = new int[n][n];  //使用邻接矩阵
            for (int j = 0; j < m; j++) {
                int x = scanner.nextInt();
                int y = scanner.nextInt();
                links[x-1][y-1] = 1;
                links[y-1][x-1] = 1;
            }

            if (helper(links,n)) System.out.println("YES");
            else System.out.println("NO");

        }
    }


    public static boolean helper(int[][] links,int n){

        //1.
        ArrayList<ArrayList<Integer>> list = new ArrayList<>();
        int[] visit = new int[n];
        for (int i = 0; i < n; i++) {
            ArrayList<Integer> temp = new ArrayList<>();
            if (visit[i] == 1) continue;

            temp.add(i);
            visit[i] = 1;
            for (int j = 0; j < n ; j++) {
                if (j != i && links[i][j] == 0 && visit[j] == 0){
                    temp.add(j);
                    visit[j] = 1;
                }
            }

            list.add(temp);
        }

        return vertify(links,list);
    }


    public static boolean vertify(int[][] links,ArrayList<ArrayList<Integer>> list){
        for (int i = 0; i < list.size(); i++) {
            ArrayList<Integer> temp = list.get(i);

            ArrayList<Integer> temp2 = new ArrayList<>();
            for (int j = i+1; j < list.size() ; j++) {
                temp2.addAll(list.get(j));
            }

            for (int j = 0; j < temp.size(); j++) {
                for (int k = 0; k < temp2.size(); k++) {
                    if (links[temp.get(j)][temp2.get(k)] == 0) return false;
                }
            }
        }

        return true;
    }

}
